package com.moyu.admin.web;

import com.moyu.admin.service.ISysUserLoginService;
import com.moyu.admin.service.IUserInfoService;
import com.moyu.data.domain.SysUserLogin;
import com.moyu.data.domain.UserInfo;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;

public class BaseController {

  @Autowired
  private IUserInfoService userInfoService;

  @Autowired
  private ISysUserLoginService userLoginService;

  public UserInfo getCurrentUser() {
    String username = (String) SecurityUtils.getSubject().getPrincipal();
    SysUserLogin userLogin = userLoginService.findByName(username);
    UserInfo user = userInfoService.getByUserId(userLogin.getId());
    return user;
  }
}
